﻿using TouchSocket.Core;
using TouchSocket.Sockets;

namespace 服务端
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var udpService = new UdpSession();
            udpService.Received = (c, e) =>
            {
                //将接收到的数据转化为HEX格式进行输出
                var hexString = e.ByteBlock.ToArray().ByBytesToHexString();
                Console.WriteLine($"接收到数据：{hexString}");
                return EasyTask.CompletedTask;
            };
            udpService.SetupAsync(new TouchSocketConfig()
                 .SetBindIPHost(new IPHost("127.0.0.1:50789")));
            udpService.StartAsync();
            Console.WriteLine("等待接收");
            Console.ReadLine();
        }
    }
}
